﻿@using LuDragon.Data.Entities;
@{
    ViewBag.Title = "后台管理中心";
    var data = ViewBag.NavList as List<Sys_Navigation>;
    var data1 = data.Where(s => s.ParentId == 0).ToList();//一级菜单集合
    var data2 = data.Where(s => s.ParentId > 0).ToList();//二级菜单集合
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=0" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/css/admin.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" media="screen and (max-width:992px)" href="~/Content/css/admin.mobile.css">
    <script src="~/Content/layui/layui.js"></script>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Content/js/tools.js"></script>
</head>
<body>
    <!-- 布局容器 -->
    <div class="layui-layout layui-layout-admin">
        <!-- 头部 -->
        <div id="header">
            <!-- 头部 -->
            <div class="layui-header">
                <div class="layui-main">
                    <div class="top-left">
                        <!-- logo -->
                        <a href="javascript:;" class="mulu"><img src="../Content/img/mulu.png" alt=""></a>
                        <a href="javascript:;" class="logo">@ViewBag.Title</a>
                        <a href="javascript:;" class="menu-flexible ml10">
                            <i class="layui-icon">&#xe635;</i>
                        </a>
                    </div>
                    <!-- 头部右侧操作 -->
                    <ul class="layui-nav operate">
                        <li class="layui-nav-item">
                            <a href="javascript:;" id="adminName"></a>
                            <dl class="layui-nav-child">
                                <dd>
                                    <a href="/User/UpdPassword" class="edit-password">修改密码</a>
                                </dd>
                                <dd>
                                    <a id="logout">退出登录</a>
                                </dd>
                            </dl>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <!-- 遮罩层 -->
        <div class="masked"></div>
        <!-- 左侧菜单 -->
        <div id="leftSlide">
            <!-- 左侧菜单 -->
            <div class="layui-side layui-bg-black left-menu-all ">
                <div class="layui-side-scroll">
                    <ul class="layui-nav layui-nav-tree left-menu" lay-filter="left-menu">
                        @for (int i = 0; i < data1.Count; i++)
                        {
                            <li class="layui-nav-item">
                                <a href="javascript:;">@data1[i].NavName</a>
                                <dl class="layui-nav-child">
                                    @for (int j = 0; j < data2.Count; j++)
                                    {
                                        if (data1[i].NavId == data2[j].ParentId)
                                        {
                                            <dd>
                                                <a onclick="OpenPage('@data2[j].Url');" data-id="@data2[j].NavId">@data2[j].NavName</a>                                          
                                            </dd>
                                        }
                                    }
                                </dl>
                            </li>
                        }
                    </ul>
                </div>
            </div>
        </div>
        <div class="layui-body">
            <!-- 主要内容 -->
            <iframe style="height:99%;width:100%;" frameborder="0" scrolling="auto" src="" id="container"></iframe>
        </div>
    </div>
    <script src="~/Content/js/fastclick.js"></script>
    <script src="~/Content/js/admin.js"></script>
</body>
</html>
<script>
    layui.use(['jquery', 'form', 'laydate', 'layer', 'laypage', 'element'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            layer = layui.layer,
            laypage = layui.laypage,
            element = layui.element;
    });
</script>
<script>
    //打开页面
    function OpenPage(url) {      
        document.getElementById('container').src = url;
    }
    $(function () {
        FastClick.attach(document.body);
        var loginInfo = localStorage.getItem("loginInfo");
        if (!loginInfo) {
            location.href = "/Login/Index"; return;
        }
        //头部
        var loginInfo = JSON.parse(localStorage.getItem("loginInfo"));
        $("#adminName").text(loginInfo.CnName);
        //退出登录
        $("#logout").click(function () {
            localStorage.clear();
            window.location.href = "/Login/Index";
            
        });      
        //监听ifarme 若是登录页则整个窗体跳转登录页 而不是ifarme跳登录页 无效弃用
        //$("#container").load(function () {
        //    var url = this.src;
        //    if (url.indexOf("Login/Index")>-1) {
        //        window.location.href = "/Login/Index";
        //    }
        //});
    })
</script>

